gdkarray: Add support for GDK_ARRAY_NO_MEMSET
authorAlexander Larsson <alexl@redhat.com>
Tue, 29 Sep 2020 14:00:30 +0000 (16:00 +0200)
committerAlexander Larsson <alexl@redhat.com>
Tue, 29 Sep 2020 14:02:59 +0000 (16:02 +0200)
If all your callers already initialize the array element as needed,
then we don't need to memset it to zero first.

This is pretty useful for the snapshot state stack, because due
to the per-node-type data area the elements on the stack are
quite large, but often a lot of it is not used.

gdk/gdkarrayimpl.c

index 65b74a3f59a3f9a34cfc060dccfbacdd7cd31bda..003c67fd59fd2c92cae395b5c27562fd5752bde3 100644 (file)
@@ -208,8 +208,10 @@ gdk_array(splice) (GdkArray *self,
         memcpy (gdk_array(index) (self, pos),
                 additions,
                 added * sizeof (_T_));
+#ifndef GDK_ARRAY_NO_MEMSET
       else
         memset (gdk_array(index) (self, pos), 0, added * sizeof (_T_));
+#endif
     }
 
 
@@ -279,5 +281,5 @@ gdk_array(get) (const GdkArray *self,
 #undef GDK_ARRAY_NULL_TERMINATED
 #undef GDK_ARRAY_PREALLOC
 #undef GDK_ARRAY_TYPE_NAME
-
+#undef GDK_ARRAY_NO_MEMSET
 #endif